import { Jwt } from './../node_modules/@types/jsonwebtoken/index.d';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { FileoperationModule } from './fileoperation/fileoperation.module';
import { LogModule } from './log/log.module';
import { LocalfileModule } from './localfile/localfile.module';
import { ConfigModule } from '@nestjs/config';
import { HttpModule } from '@nestjs/axios';
import { UserModule } from './user/user.module';
// 引入数据库
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './user/entities/user.entity';
import { AuthModule } from './auth/auth.module';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthService } from './auth/auth.service';
import { LocalStrategy } from './auth/local.strategy';
import { ChangjiangYouseModule } from './changjiang-youse/changjiang-youse.module';
import { ShanghaiJinshuModule } from './shanghai-jinshu/shanghai-jinshu.module';
import { MetalDataEntity } from './common/entities/metal-data.entity';




@Module({
  imports: [FileoperationModule, LogModule, LocalfileModule, ChangjiangYouseModule, ShanghaiJinshuModule,
    ConfigModule.forRoot({
      envFilePath: ['.env'],
      isGlobal: true,
    }),// 配置文件
    HttpModule.register({
      timeout: 5000,
      maxRedirects: 5,
    }),// http请求
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: process.env.DB_HOST,
      port: parseInt(process.env.DB_PORT),
      username: process.env.DB_USERNAME,
      password: process.env.DB_PASSWORD,
      database: process.env.DB_DATABASE,
      // entities: [__dirname + '/**/*.entity{.ts,.js}'],// 实体类
      entities: [User,MetalDataEntity],// 实体类
      synchronize: true,// 同步数据库
      autoLoadEntities: true,// 自动加载实体类
    }),// 数据库
    UserModule, AuthModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
